import 'package:fluttertoast/fluttertoast.dart';
import 'package:flutter/material.dart';

class ValToastKit {
  ///埋点页面名称
  static String loginPhonePageKey = 'loginphone'; //手机号页
  static String loginCodePageKey = 'logincode'; //验证码页


  static show(
    String msgStr,
    String pageName,{
    Toast? toastLength = Toast.LENGTH_SHORT,
    ToastGravity? gravity = ToastGravity.CENTER,
    Color? backgroundColor,
    Color? textColor = Colors.white,
    double? fontSize = 13.0,
  }) {
    Fluttertoast.showToast(
        msg: msgStr,
        toastLength: toastLength ?? Toast.LENGTH_SHORT,
        gravity: gravity ?? ToastGravity.CENTER,
        timeInSecForIosWeb: 1,
        backgroundColor: backgroundColor ?? const Color(0xff4B4B4B),
        textColor: textColor ?? Colors.white,
        fontSize: fontSize ?? 13.0);

  }

  static void showAFMessage(String message, bool isPhonePage) {
    String pageName = isPhonePage ? ValToastKit.loginPhonePageKey : ValToastKit.loginCodePageKey;
    ValToastKit.show(message, pageName);
  }

  static showMessage(
      String msgStr, {
        Toast? toastLength = Toast.LENGTH_SHORT,
        ToastGravity? gravity = ToastGravity.CENTER,
        Color? backgroundColor,
        Color? textColor = Colors.white,
        double? fontSize = 13.0,
      }) {
    Fluttertoast.showToast(
        msg: msgStr,
        toastLength: toastLength ?? Toast.LENGTH_SHORT,
        gravity: gravity ?? ToastGravity.CENTER,
        timeInSecForIosWeb: 1,
        backgroundColor: backgroundColor ?? Color(0xff4B4B4B),
        textColor: textColor ?? Colors.white,
        fontSize: fontSize ?? 13.0);
  }
}
